package com.brozha.ans_sys.controller;


import com.brozha.ans_sys.service.NewsService;
import com.brozha.ans_sys.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author brozha
 * @since 2021-04-04
 */
@RestController
@RequestMapping("/api/news")
@Api(tags = "新闻api")
@CrossOrigin
public class NewsController {

    @Autowired
    NewsService newsService;

    @GetMapping("/queryByRand")
    @ApiOperation("随机抽取十条新闻")
    public Result queryByRand(){
        return newsService.queryByRand();
    }


    @GetMapping("/query")
    @ApiOperation("分页查询新闻")
    public Result query(@RequestParam("curPage")int curPage,
                        @RequestParam("size")int size){
        return newsService.queryByPage(curPage,size);
    }

}

